package com.songyl.letcode;

import org.junit.Test;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class add_two_nums {

    @Test
    public  void test(){
        // [1,2,9]  [9,0,3]
        //921+309=1230
        //[0321]
        System.out.println(getList(1230));
        //[1,2,9]

        //[1,2,2]
        ListNode listNode1= new ListNode(1,new ListNode(2,new ListNode(2)));
        ListNode listNode2= new ListNode(1,new ListNode(9,new ListNode(2)));
        addTwoNumbers(listNode1,listNode2);
    }
    public  List getList(int num){
        int n=0;
        List <Integer> list =new ArrayList<Integer>();
        Map<Integer,Integer> map = new HashMap<Integer,Integer>();
        map.put(n,num);
        while(num>0){
            num=num/10;
            n++;
            list.add(map.get(n-1)-num*10);
            map.put(n,num);
        }
        return list;
    }
    // Definition for singly-linked list.
    public class ListNode {
        int val;
        ListNode next;
        ListNode() {}
        ListNode(int val) { this.val = val; }
        ListNode(int val, ListNode next) { this.val = val; this.next = next; }
    }

    public ListNode addTwoNumbers(ListNode l1, ListNode l2) {

        ListNode listNode =l1.next;
        while (listNode!=null){

            System.out.println(listNode.val);
            listNode =l1.next;
        }

        return  new ListNode();
    }

}




